package com.dufang.thread05SafeOrNo;

/**
 * @ClassName:MyTicket
 * @Description 线程不安全
 * @Author Administrator
 * @Date 2025/7/7/007 7:56
 * @Version 1.0
 **/
public class MyTicketNoSafe implements Runnable{
    //定义100张票
    int ticket=100;
    @Override
    public void run() {
        while (true){
            if(ticket>0){
                System.out.println(Thread.currentThread().getName()+"买了第"+ticket+"张票");
                ticket--;
            }
        }
    }
}
